Ext.define('Admin.view.logger.LoggerViewController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.loggerViewController',

    onClickLoggerGridResetButton: function(btn) {
        this.lookupReference('logSearchQuery').setValue('');
        var store = Ext.getCmp('loggerGrid').getStore();

        Ext.apply(store.proxy.extraParams, {
            fullname: '',
            oprate: '',
            ip: ''
        });

        store.load({
            params: {
                start: 0,
                limit: 20,
                page: 1
            }
        });
    },

    onClickLoggerGridSearchButton: function(btn) {
        var key = this.lookupReference('logQueryBox').getValue();
        var value = this.lookupReference('logSearchQuery').getValue();
        var store = Ext.getCmp('loggerGrid').getStore();

        if (key == null) {
            return;
        }

        Ext.apply(store.proxy.extraParams, {
            fullname: '',
            oprate: '',
            ip: ''
        });

        if (key == 'fullname') {
            Ext.apply(store.proxy.extraParams, {
                fullname: value
            })
        }

        if (key == 'oprate') {
            Ext.apply(store.proxy.extraParams, {
                oprate: value
            })
        }

        if (key == 'ip') {
            Ext.apply(store.proxy.extraParams, {
                ip: value
            })
        }

        store.load({
            params: {
                start: 0,
                limit: 20,
                page: 1
            }
        });
    },

    onClickLoggerGridExportButton:function(btn){
        window.open('log/export');
    }
});